class VideoLibraryConfigModel {
  List<PayType>? payType; //付费类型
  List<PayType>? sortType;
  List<PayType>? tags;
  List<PayType>? videoType;
  List<PayType>? timeType;

  /// acg 相关业务
  List<PayType>? tagName; //acg标签名
  List<PayType>? mediaTypes; //acg类型

  VideoLibraryConfigModel({this.payType, this.sortType, this.tags, this.videoType});

  VideoLibraryConfigModel.fromJson(Map<String, dynamic> json) {
    if (json['paymentType'] != null) {
      payType = <PayType>[];
      json['paymentType'].forEach((v) {
        payType!.add(PayType.fromJson(v, 'paymentType', '价格'));
      });
    }
    if (json['orderBy'] != null) {
      sortType = <PayType>[];
      json['orderBy'].forEach((v) {
        sortType!.add(PayType.fromJson(v, 'orderBy', '排序'));
      });
    }
    if (json['tags'] != null) {
      tags = <PayType>[];
      json['tags'].forEach((v) {
        tags!.add(PayType.fromTagJson(v, 'tags', '标签'));
      });
    }
    if (json['canvas'] != null) {
      videoType = <PayType>[];
      json['canvas'].forEach((v) {
        videoType!.add(PayType.fromJson(v, 'canvas', '类型'));
      });
    }

    timeType = (json['timeType'] as List?)?.map((e) => PayType.fromJson(e, 'timeType', '时间')).toList();

    /// acg业务
    if (json['mediaType'] != null) {
      mediaTypes = <PayType>[];
      json['mediaType'].forEach((v) {
        mediaTypes!.add(PayType.fromJson(v, 'mediaType', ''));
      });
    }
    if (json['tagName'] != null) {
      tagName = <PayType>[];
      json['tagName'].forEach((v) {
        tagName!.add(PayType.fromJson(v, 'tagName', ''));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.payType != null) {
      data['payType'] = this.payType!.map((v) => v.toJson()).toList();
    }
    if (this.sortType != null) {
      data['sortType'] = this.sortType!.map((v) => v.toJson()).toList();
    }
    if (this.tags != null) {
      data['tags'] = this.tags!.map((v) => v.toJson()).toList();
    }
    if (this.videoType != null) {
      data['videoType'] = this.videoType!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class PayType {
  String? key;
  String? name;
  String? type;
  String? title;
  String? value;
  // 调整布局位置
  double? childRatio;
  bool? isGridStyle;

  PayType({this.key, this.name});

  PayType.fromJson(Map<String, dynamic> json, String type_, String title_) {
    key = json['key'];
    name = json['name'];
    type = type_;
    title = title_;
    value = json['value'];

    if (type == 'canvas') {
      if (name == '影片') {
        childRatio = 191 / 174;
        isGridStyle = true;
      } else if (name == '抖音') {
        childRatio = 168 / 248;
        isGridStyle = true;
      } else {
        isGridStyle = false;
      }
    }
  }

  PayType.fromTagJson(Map<String, dynamic> json, String type_, String title_) {
    key = json['id'];
    name = json['name'];
    type = type_;
    title = title_;
    value = json['value'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['key'] = this.key;
    data['name'] = this.name;
    return data;
  }
}
